{
	arguments: {
		name: '<?php echo $_POST['name']; ?>',
		comment: '<?php echo str_replace("\n", "\\n", $_POST['comment']);?>',
        mail: '<?php echo $_POST['mail'];?>',
        idParent: '<?php echo $_POST['idParent'];?>',
	},
<?php
if (!$_POST['name'] and !$_POST['comment'] and !$_POST['mail']) {
?>
	type: 'error',
	error: 'All fields are required.'
<?php
} else {
	if(Valid::email($_POST['mail'])) {
		$result = Comment::create(utf8_decode($_POST['name']), utf8_decode($_POST['comment']), $_POST['idParent'], $_POST['mail']);
		if ($result) {
			$comment = new Comment();
			$comment = $comment->get_most_recent();
	?>
		type: 'success',
		entry: {
			idComment: '<?php echo $comment->get_id(); ?>',
			title: '<?php echo $comment->get_title(); ?>',
			content: '<?php echo $comment->get_content(); ?>',
			slug: '<?php echo $comment->slug; ?>',
			creationDate: '<?php echo $comment->creationDate; ?>',
			idParent: '<?php echo $comment->id_parent; ?>',
			type: '<?php echo $comment->type; ?>'
		}
    
<?php
		}		
	} else {
?>
	type: 'error',
	error: 'The email address is not valid.'
<?php
	}
}
?>
}
<?php
exit;
?>